/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.animation.transformations;

import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.api.Generator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.helpergenerators.TransformGenerator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.helpergenerators.TransformParamChecker;
import pl.edu.amu.wmi.kino.visualjavafx.model.animation.transformations.Scale;
import pl.edu.amu.wmi.kino.visualjavafx.model.objects.VisualObject;

/**
 *
 * @author Admin
 */
//TODO : Grzegorz : WORKS, BUT HAVE TO TRANSLATE IN 0s KEYFRAME TO STATING POS!!
public class ScaleGenerator implements Generator{

    @Override
    public boolean canGenerate(Object c) {
        if(c instanceof Scale)
            return true;
        else return false;
    }

    @Override
    public void generate(StringBuilder sb, Object o,int recursionLevel,Object original) {
        
        this.generateScaleX(sb, (Scale)o, recursionLevel,original);
        this.generateScaleY(sb, (Scale)o, recursionLevel,original);
    }

    private void generateScaleX(StringBuilder sb,Scale s,int recursionLevel,Object original){
        VisualObject v = (VisualObject)original;

        if(TransformParamChecker.generateParam(s.getHDestinedSize()))
        sb.append(TransformGenerator.scaleX+recursionLevel+" => "+
                (s.getHDestinedSize()/v.getSizeH())+
                " tween Interpolator."+s.getInterpolations()[0].getName()+",\n");
    }
    private void generateScaleY(StringBuilder sb,Scale s,int recursionLevel,Object original){
        VisualObject v = (VisualObject)original;

        if(TransformParamChecker.generateParam(s.getVDestinedSize()))
        sb.append(TransformGenerator.scaleY+recursionLevel+" => "+
                (s.getVDestinedSize()/v.getSizeV())+
                " tween Interpolator."+s.getInterpolations()[0].getName()+",\n");
    }

}
